home *** CD-ROM | disk | FTP | other *** search
- Path: news.cencom.net!ns!tanp
- From: tanp@ns (Bill Wendling)
- Newsgroups: comp.lang.c
- Subject: Re: #define, question from a beginner
- Date: 6 Feb 1996 07:04:58 GMT
- Organization: Cen-Com Internet
- Message-ID: <4f6uiq$rt1@news.cencom.net>
- References: <ma-010296161301@mac147.maths.uwa.edu.au> <31109AF8.423B@zess.uni-siegen.de> <TANMOY.96Feb1095641@qcd.lanl.gov> <31165CA1.2781E494@texas.net>
- NNTP-Posting-Host: ns.cencom.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- Michael Douglass inexplicably wrote:
- } What I'm trying to figure out is *why* you want to include comments
- } inside of a macro anyways... The only thing that would see the expanded
- } version w/ comments would be the compiler after preprocessing... Which
- } would then barf on comments because the preprocessor takes the comments
- } out... (Doesn't it?)
-
- You want to be careful when putting comments into a macro. Take, for
- instance, this (comments in C++, but the example's comments were in
- C++ sooo..):
-
- #define MACRO printf("%d ", j); //cmnt \
- /*cmnt*/ \
- printf("%d", k); //cmnt.
-
- This macro will expand to:
-
- printf("%d ", j); //cmnt /*cmnt */ printf("%d", k); //cmnt.
-
- And you will only be printing out the value of j.
-
- --
- Bill Wendling | "Pinky, are you thinking what I'm thinking?"
- tanp@ns.cencom.net | "I think so, Brain, but burlap chafes me so."
- "Boom Shanka" | Finger me for my Geek Code...NOW!
-